package com.kmxd.ams.controller.system;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kmxd.ams.client.system.ISysDictTabsetSvc;
import com.kmxd.ams.client.system.dto.SysDictTabsetAddDTO;
import com.kmxd.ams.client.system.dto.SysDictTabsetEditDTO;
import com.kmxd.ams.client.system.dto.SysDictTabsetQueryDTO;
import com.kmxd.ams.client.system.vo.SysDictTabsetListVO;
import com.kmxd.ams.client.system.vo.SysDictTabsetVO;
import com.kmxd.ams.core.common.enums.LogLevelEnum;
import com.kmxd.ams.core.common.enums.LogTypeEnum;
import com.kmxd.ams.core.log.annotation.AutoLog;
import com.kmxd.ams.core.result.R;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 字典扩展 前端控制器
 *
 * @author ZuoLG
 * @since 2022-07-13
 */
@Tag(name = "字典扩展")
@RestController
@RequestMapping("/system/sysDictTabset")
@AllArgsConstructor
public class SysDictTabsetCtl {

  private ISysDictTabsetSvc sysDictTabsetService;

  /** 分页查询 */
  @GetMapping("/selectPage")
  @AutoLog(module = "字典扩展", type = LogTypeEnum.SYSTEM, level = LogLevelEnum.LOW, title = "分页查询")
  public R<Page<SysDictTabsetListVO>> selectPage(Page reqPage, SysDictTabsetQueryDTO req) {
    return R.success(sysDictTabsetService.selectPage(reqPage, req));
  }

  @GetMapping("/list")
  @SaCheckPermission("system:sysDictTabset:list")
  @AutoLog(module = "字典扩展", type = LogTypeEnum.SYSTEM, level = LogLevelEnum.LOW, title = "列表查询")
  public R<List<SysDictTabsetListVO>> list(SysDictTabsetQueryDTO req) {
    return R.success(sysDictTabsetService.list(req));
  }

  /** 新增 */
  @PostMapping("/add")
  @SaCheckPermission("system:sysDictTabset:add")
  @AutoLog(module = "字典扩展", type = LogTypeEnum.SYSTEM, level = LogLevelEnum.LOW, title = "新增")
  public R<Void> add(@Validated @RequestBody SysDictTabsetAddDTO req) {
    sysDictTabsetService.add(req);
    return R.success();
  }

  /** 修改 */
  @PostMapping("/edit")
  @SaCheckPermission("system:sysDictTabset:edit")
  @AutoLog(module = "字典扩展", type = LogTypeEnum.SYSTEM, level = LogLevelEnum.HIGH, title = "修改")
  public R<Void> edit(@Validated @RequestBody SysDictTabsetEditDTO req) {
    sysDictTabsetService.edit(req);
    return R.success();
  }

  /** 删除 */
  @PostMapping("/remove")
  @SaCheckPermission("system:sysDictTabset:remove")
  @AutoLog(module = "字典扩展", type = LogTypeEnum.SYSTEM, level = LogLevelEnum.HIGH_RISK, title = "删除")
  public R<Void> remove(@RequestParam String ids) {
    sysDictTabsetService.remove(ids);
    return R.success();
  }

  /** 查看 */
  @GetMapping("/view")
  @AutoLog(module = "字典扩展", type = LogTypeEnum.SYSTEM, level = LogLevelEnum.LOW, title = "查看")
  public R<SysDictTabsetVO> view(@RequestParam Long id) {
    return R.success(sysDictTabsetService.view(id));
  }
}
